package com.htsk.city.services.wechat.controller;

import com.htsk.city.services.core.domain.WxUser;
import com.htsk.city.services.core.entity.PageInfo;
import com.htsk.city.services.core.entity.R;
import com.htsk.city.services.wechat.annotation.GetUserInfo;
import com.htsk.city.services.wechat.params.TechnicianQueryParam;
import com.htsk.city.services.wechat.service.TechnicianService;
import com.htsk.city.services.wechat.vo.TechnicianAddVo;
import com.htsk.city.services.wechat.vo.TechnicianVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("technician")
public class TechnicianController {
    @Resource
    private TechnicianService technicianService;

    @PostMapping("queryTechnicians")
    public R<PageInfo> queryTechnicians(@RequestBody TechnicianQueryParam technicianQueryParam) {
        return technicianService.getTechnicians(technicianQueryParam);
    }

    /**
     * 查询师傅类型
     * @return
     */
    @PostMapping("queryTechnicianType")
    public R<List<Map<String,Object>>> queryTechnicianType(@RequestParam("cityId") Long cityId) {
        return technicianService.queryTechnicianType(cityId);
    }

    /**
     * 师傅收藏
     * @return
     */
    @PostMapping("addTechnicianFavorite")
    public R<Integer> addTechnicianFavorite(@GetUserInfo WxUser wxUser, @RequestParam("technicianId") Integer technicianId) {
        return technicianService.addTechnicianFavorite(wxUser,technicianId);
    }
    /**
     * 师傅取消收藏
     * @return
     */
    @PostMapping("delTechnicianFavorite")
    public R<Integer> delTechnicianFavorite(@GetUserInfo WxUser wxUser, @RequestParam("technicianId") Integer technicianId) {
        return technicianService.delTechnicianFavorite(wxUser,technicianId);
    }
    /**
     * 师傅明细
     * @return
     */
    @GetMapping("getTechnicianDetail")
    public R<TechnicianVO> getTechnicianDetail(@RequestParam("technicianId") Long technicianId) {
        return technicianService.technicianDetail(technicianId);
    }

    /**
     * 成为专家
     * @param wxUser
     * @param technicianAddVo
     * @return
     */
    @PostMapping("addTechnician")
    public R addTechnician(@GetUserInfo WxUser wxUser, @RequestBody TechnicianAddVo technicianAddVo) {
        return technicianService.addTechnician(wxUser, technicianAddVo);
    }


}
